/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.desitek.thunder.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dt
 */
@Entity
@Table(name = "app_user",   schema = "public", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"username"}),
    @UniqueConstraint(columnNames = {"email_id"}),
    @UniqueConstraint(columnNames = {"activation_key"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AppUser.findAll", query = "SELECT a FROM AppUser a"),
    @NamedQuery(name = "AppUser.findById", query = "SELECT a FROM AppUser a WHERE a.id = :id"),
    @NamedQuery(name = "AppUser.findByUsername", query = "SELECT a FROM AppUser a WHERE a.username = :username"),
    @NamedQuery(name = "AppUser.findByPassword", query = "SELECT a FROM AppUser a WHERE a.password = :password"),
    @NamedQuery(name = "AppUser.findByEmailId", query = "SELECT a FROM AppUser a WHERE a.emailId = :emailId"),
    @NamedQuery(name = "AppUser.findByEnabled", query = "SELECT a FROM AppUser a WHERE a.enabled = :enabled"),
    @NamedQuery(name = "AppUser.findByLastUpdate", query = "SELECT a FROM AppUser a WHERE a.lastUpdate = :lastUpdate"),
    @NamedQuery(name = "AppUser.findByJoinedOn", query = "SELECT a FROM AppUser a WHERE a.joinedOn = :joinedOn"),
    @NamedQuery(name = "AppUser.findByDob", query = "SELECT a FROM AppUser a WHERE a.dob = :dob"),
    @NamedQuery(name = "AppUser.findByActivationKey", query = "SELECT a FROM AppUser a WHERE a.activationKey = :activationKey"),
    @NamedQuery(name = "AppUser.findByActivated", query = "SELECT a FROM AppUser a WHERE a.activated = :activated"),
    @NamedQuery(name = "AppUser.findByFirstName", query = "SELECT a FROM AppUser a WHERE a.firstName = :firstName"),
    @NamedQuery(name = "AppUser.findByLastName", query = "SELECT a FROM AppUser a WHERE a.lastName = :lastName"),
    @NamedQuery(name = "AppUser.findByMiddleName", query = "SELECT a FROM AppUser a WHERE a.middleName = :middleName"),
    @NamedQuery(name = "AppUser.findByToken", query = "SELECT a FROM AppUser a WHERE a.token = :token"),
    @NamedQuery(name = "AppUser.findBySeries", query = "SELECT a FROM AppUser a WHERE a.series = :series")})
public class AppUser implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Long id;
    @Column(name = "username", length = 13)
    private String username;
    @Column(name = "password", length = 250)
    private String password;
    @Column(name = "email_id", length = 500)
    private String emailId;
    @Column(name = "enabled")
    private Boolean enabled;
    @Column(name = "last_update")
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdate;
    @Column(name = "joined_on")
    @Temporal(TemporalType.TIMESTAMP)
    private Date joinedOn;
    @Column(name = "dob")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dob;
    @Column(name = "activation_key", length = 100)
    private String activationKey;
    @Column(name = "activated")
    private Boolean activated;
    @Column(name = "first_name", length = 250)
    private String firstName;
    @Column(name = "last_name", length = 250)
    private String lastName;
    @Column(name = "middle_name", length = 250)
    private String middleName;
    @Column(name = "token", length = 70)
    private String token;
    @Column(name = "series", length = 250)
    private String series;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "appUser")
    private UserGroupList userGroupList;

    public AppUser() {
    }

    public AppUser(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmailId() {
        return emailId;
    }

    public void setEmailId(String emailId) {
        this.emailId = emailId;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Date getLastUpdate() {
        return lastUpdate;
    }

    public void setLastUpdate(Date lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    public Date getJoinedOn() {
        return joinedOn;
    }

    public void setJoinedOn(Date joinedOn) {
        this.joinedOn = joinedOn;
    }

    public Date getDob() {
        return dob;
    }

    public void setDob(Date dob) {
        this.dob = dob;
    }

    public String getActivationKey() {
        return activationKey;
    }

    public void setActivationKey(String activationKey) {
        this.activationKey = activationKey;
    }

    public Boolean getActivated() {
        return activated;
    }

    public void setActivated(Boolean activated) {
        this.activated = activated;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getSeries() {
        return series;
    }

    public void setSeries(String series) {
        this.series = series;
    }

    public UserGroupList getUserGroupList() {
        return userGroupList;
    }

    public void setUserGroupList(UserGroupList userGroupList) {
        this.userGroupList = userGroupList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AppUser)) {
            return false;
        }
        AppUser other = (AppUser) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.desitek.thunder.entity.AppUser[ id=" + id + " ]";
    }
    
}
